immulticontext: Unset client widget on delegate change
authorMatthias Clasen <mclasen@redhat.com>
Sat, 3 Apr 2021 02:24:19 +0000 (22:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 3 Apr 2021 02:24:19 +0000 (22:24 -0400)
Forgetting to do so was causing the Wayland im context
to leave behind a dead event controller. This was showing
up as a crash when closing the inspector after changing
the im-module property of a GtkText widget. The crash
was delayed until closing the inspector because the
inspector keeps a ref on the event controllers of the
currently shown widget.

gtk/gtkimmulticontext.c

index 40b80d42d40335d46dbd90683c88d468b951ac59..f26f1dd05c34845e047f1b437f9f5c9dd8f6b979 100644 (file)
@@ -205,6 +205,9 @@ gtk_im_multicontext_set_delegate (GtkIMMulticontext *multicontext,
                                            gtk_im_multicontext_delete_surrounding_cb,
                                            multicontext);
 
+      if (priv->client_widget)
+        gtk_im_context_set_client_widget (priv->delegate, NULL);
+
       g_object_unref (priv->delegate);
       priv->delegate = NULL;